//
//  YSEMSProListCell.m
//  YaSha-iOS
//
//  Created by 方鹏俊 on 2017/11/21.
//

#import "YSEMSProListCell.h"

@interface YSEMSProListCell ()

@property (nonatomic, strong) UILabel *proNameLabel;
@property (nonatomic, strong) UIButton *selectedButton;

@end

@implementation YSEMSProListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initUI];
    }
    return self;
}

- (void)initUI {
   // _sendSelectedSubject = [RACSubject subject];
    
//    _selectedButton = [[UIButton alloc] init];
//    [_selectedButton setImage:UIImageMake(@"选择项目-未选") forState:UIControlStateNormal];
//    [_selectedButton setImage:UIImageMake(@"选择项目-选中") forState:UIControlStateSelected];
//    _selectedButton.userInteractionEnabled = NO;
//
//    [[_selectedButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(UIButton *button) {
//        [_sendSelectedSubject sendNext:button];
//    }];
//    [self.contentView addSubview:_selectedButton];
//
//    [_selectedButton mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.mas_equalTo(self.contentView.mas_centerY);
//        make.right.mas_equalTo(self.contentView.mas_right).offset(-15);
//        make.size.mas_equalTo(CGSizeMake(30, 30));
//    }];
    
    _proNameLabel = [[UILabel alloc] init];
    _proNameLabel.font = [UIFont systemFontOfSize:16];
    _proNameLabel.numberOfLines = 0;
    [self.contentView addSubview:_proNameLabel];
    [_proNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentView.mas_top).offset(10);
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.left.mas_equalTo(self.contentView.mas_left).offset(15);
        make.right.mas_equalTo(_selectedButton.mas_left).offset(-10);
        make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-10);
    }];
//    //点击button
//    UIButton *clickBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    [self.contentView addSubview:clickBtn];
//    [[clickBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
//        _selectedButton.selected = !_selectedButton.selected;
//        _cellModel.isSelected = !_cellModel.isSelected;//选中状态记录model里
//        [_sendSelectedSubject sendNext:x];
//    }];
//    [clickBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.edges.mas_equalTo(0);
//    }];
}
//- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
//    [super setSelected:selected animated:animated];
//    _selectedButton.selected = selected;
//    _cellModel.isSelected = selected;//选中状态记录model里
//}
- (void)setCellModel:(YSEMSProListModel *)cellModel {
    _cellModel = cellModel;
    _proNameLabel.text = _cellModel.name;
//    _selectedButton.selected = _cellModel.isSelected;
}

@end
